package com.example.springbootnettydemo;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class NettyServerInitializer {

    private final int port;

    public NettyServerInitializer(@Value("${netty.port:8080}") int port) {
        this.port = port;
    }

    @PostConstruct
    public void startNettyServer() {
        try {
            new NettyServer(port).start();
        } catch (Exception e) {
        }
    }
}